<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Rank extends My_Controller{
	
	public static  $m_Type = array(
			DOUBAN_TYPE,
	);
	
	public static $m_baseID = 1000000;

	public function __construct()
	{
		parent::__construct();
	
		if (empty($this->m_arrUser))
		{
			redirect('account/login?reUrl=index.php/douban/rank');
			exit;
		}
		
		$this->load->library('my_api',self::$m_Type);
	
		$this->load->model('date_m');

	}
		
	public function index()
	{
		$this->m_arrSub = array(
				'common/header'  =>  'index',
				'common/footer'  => 'index',
		);
		$this->addStyle('public/css/douban/rank.css');
	
	
		$this->getSub();
	
		// 获取豆瓣的个人信息..
	
		$data = array(
				'id' => $this->my_api->douban_uid,
		);
	
		$doubanUserInfo  = $this->my_api->douban->api('User.info.GET',$data)->makeRequest();
	
		$this->data['userInfo'] = array(
				'name' =>$doubanUserInfo['name'],
				'city'=>$doubanUserInfo['loc_name'],
				'avatar' =>"http://img3.douban.com/icon/ul".$doubanUserInfo['id']."-22.jpg",
				'rank' =>$doubanUserInfo['id'] -  self::$m_baseID,
				'time' => $doubanUserInfo['created'],
				'url' => $doubanUserInfo['alt'],
		);
	
		// 获取豆瓣的关注者且为朋友信息..
		
		$data = array(
				'id' => $this->my_api->douban_uid,
				'tag' => 1,
 				'start' => 0,
				'count' => 100,

		);
		
		$doubanFollowList  = $this->my_api->douban->api('Miniblog.following.GET',$data)->makeRequest();
		
		$this->data['followList'] = array();
		
	    foreach ($doubanFollowList as $follow)
	    {
	    	$this->data['followList'][] = array(
	    			'name' =>$follow['screen_name'],
					'city'=>$follow['city'],
					'avatar' =>$follow['small_avatar'],
					'rank' =>$follow['id'] -  self::$m_baseID,
					'time' => $follow['created_at'],
	    			'url' => $follow['url'],
	    			);
	    }
		

		$this->load->view('douban/rank',$this->data);
	}
}